package com.platform.corejwt.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import org.springframework.util.StringUtils;

/**
 * describe:
 *
 * @author Administrator
 * @date 2019/07/20
 * @Time 10:35
 */
public class JwtUtil {

    public static String getToken(String userName){
        if(!StringUtils.isEmpty(userName)){
            return JWT.create().withAudience(userName).sign(Algorithm.HMAC256("123"));
        }else {
            return null;
        }
    }

    public static void encodeToken(String token){
        JWT.decode(token).getHeader();
    }
}
